package br.net.woodstock.tickettoride.client.jdk6.ws.jee;

import br.net.woodstock.tickettoride.client.TicketException;
import br.net.woodstock.tickettoride.client.TicketService;
import br.net.woodstock.tickettoride.client.TicketSession;
import br.net.woodstock.tickettoride.client.config.TicketConfig;
import br.net.woodstock.tickettoride.client.jdk6.ws.jee.internal.TicketServiceWS;

class TicketServiceJEE implements TicketService {

	private TicketServiceWS	ws;

	public TicketServiceJEE(final TicketServiceWS ws) {
		super();
		this.ws = ws;
	}

	@Override
	public TicketSession getSession() {
		try {
			br.net.woodstock.tickettoride.client.jdk6.ws.jee.internal.TicketSession session = this.ws.createSession(TicketConfig.getInstance().getApplicationAlias());
			TicketSessionImpl sessionImpl = new TicketSessionImpl(this.ws, session.getHash(), session.getKey());
			return sessionImpl;
		} catch (Exception e) {
			throw new TicketException(e);
		}
	}

}
